﻿// <copyright file="Profile.cs" company="Microsoft Corporation">
// Copyright (c) 2009 Microsoft Corporation All Rights Reserved
// </copyright>
// <author>Michael S. Scherotter</author>
// <email>mischero@microsoft.com</email>
// <date>2009-05-06</date>
// <summary>TimesPeople Profile class definition</summary>

namespace NYTimes.Data
{
    using System;
    using System.Globalization;
    using System.Windows.Media.Imaging;

    /// <summary>
    /// TimesPeople Profile
    /// </summary>
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1724:TypeNamesShouldNotMatchNamespaces", Justification = "System.Web.Profile is not in Silverlight.")]
    public class Profile
    {
        /// <summary>
        /// Gets or sets the user’s unique TimesPeople ID number.
        /// </summary>
        public long UserId { get; set; }

        /// <summary>
        /// Gets or sets the user's display name, as it appears in the TimesPeople toolbar and in news feeds.
        /// </summary>
        public string DisplayName { get; set; }

        /// <summary>
        /// Gets or sets the user's location, as it appears on his or her profile page. The value of location does not have to be a geographic place name; users can specify any location, such as “my couch,” and can change the location at any time.
        /// </summary>
        public string Location { get; set; }

        /// <summary>
        /// Gets or sets the user’s profile image, as it appears on profile pages and in news feeds. Images are in .png, .gif (non-animated) or .jpg format. There is no size restriction for images.
        /// </summary>
        public Uri PictureUrl { get; set; }

        /// <summary>
        /// Gets the user’s profile image, as it appears on profile pages and in news feeds. Images are in .png or .jpg format. There is no size restriction for images.
        /// </summary>
        public BitmapImage Picture
        {
            get
            {
                if (this.PictureUrl == null)
                {
                    return null;
                }

                // GIF Images are not supported in Silverlight
                if (this.PictureUrl.ToString().EndsWith(".gif", StringComparison.OrdinalIgnoreCase))
                {
                    return null;
                }

                return new BitmapImage(this.PictureUrl);
            }
        }

        /// <summary>
        /// Gets or sets the number of people this user is following
        /// </summary>
        public int Following { get; set; }

        /// <summary>
        /// Gets or sets the number of people that are following this user
        /// </summary>
        public int Followers { get; set; }

        /// <summary>
        /// Gets the TimesPeople Activities URL
        /// </summary>
        public Uri ActivitiesUrl
        {
            get
            {
                var uriString = string.Format(
                    CultureInfo.InvariantCulture,
                    "http://timespeople.nytimes.com/view/user/{0}/activities.html",
                    this.UserId);

                return new Uri(uriString, UriKind.Absolute);
            }
        }

        /// <summary>
        /// Gets or sets the User Bio
        /// </summary>
        /// /// <remarks>uses the user_bio element</remarks>
        public string Bio { get; set; }

        /// <summary>
        /// Gets or sets the User Url
        /// </summary>
        /// <remarks>uses the user_url element</remarks>
        public Uri Url { get; set; }
    }
}
